home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TeX 1995 July
/
TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO
/
web
/
noweb
/
src
/
c
/
columns.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-24
|
821b
|
33 lines
#line 19 "columns.nw"
#include <stdio.h>
#include "columns.h"
int tabsize = 8;
#line 24 "columns.nw"
int columnwidth (char *s) { /* width of a string in columns */
return limitcolumn(s, 0);
}
#line 29 "columns.nw"
int limitcolumn (char *s, int col) {
while (*s) {
col++;
if (*s=='\t' && tabsize > 0) while (col % tabsize != 0) col++;
s++;
}
return col;
}
#line 39 "columns.nw"
void indent_for (int width, FILE *fp) {
/* write whitespace [[width]] columns wide */
/*fprintf(fp,"<%2d>",width); if (width>4) {fprintf(fp," "); width -= 4;}*/
if (tabsize > 1)
while (width >= tabsize) {
putc('\t', fp);
width -= tabsize;
}
while (width > 0) {
putc(' ', fp);
width--;
}
}